package cn.calm.swing.osgi.file.New.ui;

import java.awt.Component;

import javax.swing.JTree;
import javax.swing.tree.DefaultTreeCellRenderer;

import cn.calm.swing.osgi.api.ui.IconDefaultMutableTreeNode;

public class IconDefaultTreeCellRenderer extends DefaultTreeCellRenderer {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean sel, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
		if(value instanceof IconDefaultMutableTreeNode){
			setLeafIcon(((IconDefaultMutableTreeNode) value).getIcon());
		}
		return super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf,
				row, hasFocus);
	}
}
